<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>JavaScript DOM修改元素内容</title>
    </head>
    <body>
        <h3>JavaScript DOM修改元素内容</h3>
        <hr />
        <p id="test"><i>Hello 2016</i></p>
        <script>
		//获取id="test"的段落元素对象
		var p = document.getElementById("test");
		//获取该段落元素对象的初始内容
		var msg = p.innerHTML;
		//改变该段落元素对象的内容
		p.innerHTML = "<strong>Hello 2017</strong>";
		alert("段落元素的初始内容是：\n"+msg);
        </script>
    </body>
</html>